package com.db.message;

import java.sql.*;
import java.util.*;
import java.io.*;

import javax.annotation.Resource;

import com.ibatis.common.resources.*;
import com.ibatis.sqlmap.client.*;

public class MessageDAO {

	public static SqlMapClient sqlmap;
	static {
		try {
			Reader reader = Resources
					.getResourceAsReader("com/db/config/SqlMapConfig.xml");
			sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (Exception ex) {
			System.out.println("static : " + ex.getMessage());
		}
	}

	public static List sendAllData(String id) throws Exception {

		return sqlmap.queryForList("sendAllData", id);
	}

	public static List recvAllData(String id) throws Exception {

		return sqlmap.queryForList("recvAllData", id);
	}

	public static void msgSend(MessageVO vo) throws Exception {
		sqlmap.insert("msgSend", vo);
	}

	public static MessageVO msgContentData(int no) throws Exception {
		return (MessageVO) sqlmap.queryForObject("msgContentData", no);
	}

	public static void msgSendDelete(int no) throws Exception {
		sqlmap.update("msgSendDelete", no);
	}

	public static void msgRecvDelete(int no) throws Exception {
		sqlmap.update("msgRecvDelete", no);
	}

	public static void allSendDelete(String send_id) throws Exception {
		sqlmap.update("allSendDelete", send_id);
	}

	public static void allRecvDelete(String recv_id) throws Exception {
		sqlmap.update("allRecvDelete", recv_id);
	}

	public static void msgAllDelete() throws Exception {
		sqlmap.delete("msgAllDelete");
	}

}
